package cn.isaac.firstkotlin.clazz

import android.content.Context
import android.os.Bundle
import android.widget.Toast

/**
 * Created by RaoWei on 2017/5/19 13:54.
 */

class firstKt(name: String, surname: String = "默认值"){
    init {
        println("构造函数的函数体-->>在此,name=${name},surname=${surname}")
    }
}

open class Animal(name: String)

class Person(name: String, surname: String) : Animal(name) {
    fun onCreate(savedInstanceState: Bundle?) {}

    fun add(x: Int, y: Int) : Int {
        return x + y
    }

    fun add2(x: Int, y: Int) = x+y

    fun Context.toast(message: String, length: Int = Toast.LENGTH_SHORT) {
        Toast.makeText(this, message, length).show()
    }

//    fun Context.niceToast(message: String, tag: String = javaClass<MainActivity>().getSimpleName(), length: Int = Toast.LENGTH_SHORT) {
//        Toast.makeText(this, "[$tag] $message", length).show()
//    }

}

public class Personn {
    var name: String = ""
    get() = field.toUpperCase()
    set(value) {field = "Name:$value"}

    var surname: String = ""
    get() = field.toUpperCase()
    set(value) {field = "Surname:$value"}
}